<template>
  <div class="analyse">
    <barChart :barData="dataArr" :xData="xData" />
  </div>
</template>

<script>
import barChart from "@/views/home/analyse/components/barChart.vue";
export default {
  name: "analyse",
  props: {
    activeName: {
      type: String,
      default: "0",
    },
  },
  components: {
    barChart,
  },
  data() {
    return {
      dataArr: [],
      xData: [],
    };
  },
  watch: {
    activeName: {
      handler(val) {
        if (val && val == "1") {
          setTimeout(() => {
            this.getBarData();
          }, 500);
        }
      },
      immediate: true,
      deep: false,
    },
  },
  methods: {
    getBarData() {
      this.dataArr = [
        {
          name: "节省成本",
          data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          type: "bar",
        },
        {
          name: "超支成本",
          data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          type: "bar",
        },
      ];
      this.xData = [
        "1月",
        "2月",
        "3月",
        "4月",
        "5月",
        "6月",
        "7月",
        "8月",
        "9月",
        "10月",
        "11月",
        "12月",
      ];
    },
  },
};
</script>

<style scoped lang="scss">
.analyse {
  width: 100%;
}
</style>
